/**
 * @file main.c
 * @author etcfly (etcflywy@126.com)
 * @brief 
 * @version 1.0.0
 * @date 2025-07-22
 * 
 * @copyright Copyright (c) 2025
 * 
 */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "elf_parse.h"

int main(int argc, char *argv[])
{
    if (argc != 2) {
        perror("invalid para!\r\n");
        return -1;
    }

    FILE *fp = fopen(argv[1], "r");
    if (fp == NULL) {
        return -1;
    }

    fseek(fp, 0, SEEK_END);
    int size = ftell(fp);
    if (size <= 0) {
        fclose(fp);
        return -1;
    }

    fseek(fp, 0, SEEK_SET);
    char *fbuff = malloc(size);
    if (fbuff == NULL) {
        fclose(fp);
        return -1;
    }

    if (size != fread(fbuff, 1, size, fp)) {
        fclose(fp);
        return -1;
    }

    elf_parse(fbuff);

    free(fbuff);
    fclose(fp);
    return 0;
}